package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.product.BaseCategoryTrademark;
import com.atguigu.gmall.model.product.BaseTrademark;
import com.atguigu.gmall.model.product.CategoryTrademarkVo;
import com.atguigu.gmall.product.service.BaseCategoryTrademarkService;
import com.baomidou.mybatisplus.extension.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("admin/product/baseCategoryTrademark")
public class BaseCategoryTrademarkController {

    @Autowired
    private BaseCategoryTrademarkService baseCategoryTrademarkService;

    @GetMapping("findTrademarkList/{category3Id}")
    public Result findTrademarkList(@PathVariable("category3Id") Long category3Id) {
        List<BaseTrademark> baseCategoryTrademarks = baseCategoryTrademarkService.findTrademarkList(category3Id);
        return Result.ok(baseCategoryTrademarks);
    }

    @PostMapping("save")
    public Result save(@RequestBody CategoryTrademarkVo categoryTrademarkVo) {
        //保存方法
        baseCategoryTrademarkService.save(categoryTrademarkVo);
        return Result.ok();
    }


    @GetMapping("findCurrentTrademarkList/{category3Id}")
    public Result findCurrentTrademarkList(@PathVariable("category3Id") Long category3Id) {
        List<BaseTrademark> baseTrademarks = baseCategoryTrademarkService.findCurrentTrademarkList(category3Id);
        return Result.ok(baseTrademarks);
    }

    @DeleteMapping("remove/{category3Id}/{trademarkId}")
    public Result remove(@PathVariable("category3Id") Long category3Id, @PathVariable("trademarkId") Long trademarkId) {
        baseCategoryTrademarkService.remove(category3Id, trademarkId);

        return Result.ok();
    }


}
